package com.weirdor.wxchat.www.web;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.weirdor.wxchat.module.entity.QywxGzentity;
import com.weirdor.wxchat.module.service.IQywxGzentityService;
import com.weirdor.wxchat.support.utils.R;
import com.xiaoleilu.hutool.convert.Convert;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;

/**
 * 关注回复
 * 
 * @author weirdor
 * @email 179946422@qq.com
 * @date 2017-12-01 16:34:57
 */
@RestController
@RequestMapping("/module/qywxgzentity")
public class QywxGzentityController {

	@Autowired
	private IQywxGzentityService qywxGzentityService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("module:qywxgzentity:list")
	public R list(@RequestParam Map<String, Object> params){
		EntityWrapper<QywxGzentity> wrapper = new EntityWrapper<QywxGzentity>();

		Page<QywxGzentity> pageUtil=qywxGzentityService.selectPage(new Page<QywxGzentity>(Convert.toInt(params.get("page")),Convert.toInt(params.get("limit"))),wrapper);
		return R.ok().put("page", pageUtil);
	}

	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("module:qywxgzentity:info")
	public R info(@PathVariable("id") String id){
		QywxGzentity qywxGzentity = qywxGzentityService.selectById(id);

		return R.ok().put("qywxGzentity", qywxGzentity);
	}

	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("module:qywxgzentity:save")
	public R save(@RequestBody QywxGzentity qywxGzentity){
		qywxGzentityService.insert(qywxGzentity);

		return R.ok();
	}

	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("module:qywxgzentity:update")
	public R update(@RequestBody QywxGzentity qywxGzentity){
		qywxGzentityService.updateById(qywxGzentity);

		return R.ok();
	}

	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("module:qywxgzentity:delete")
	public R delete(@RequestBody String[] ids){
		EntityWrapper<QywxGzentity> entityWrapper=new EntityWrapper<>();
		entityWrapper.in("id",ids);
		qywxGzentityService.delete(entityWrapper);
		return R.ok();
	}

}
